/*
 * Person.cpp
 *
 *  Created on: 22/04/2012
 *      Author: alex
 */

#include "ElevatorPassenger.h"
#include <cstring>
#include <sstream>

using namespace std;

ElevatorPassenger::ElevatorPassenger(FloorIdentifier destination, float weight)
{
    m_DestinationFloor = destination;
    m_Weight = weight;
}

ElevatorPassenger::ElevatorPassenger(ElevatorPassenger & orig)
{
	m_DestinationFloor = orig.m_DestinationFloor;
	m_Weight = orig.m_Weight;
}


ElevatorPassenger::~ElevatorPassenger()
{
}

FloorIdentifier ElevatorPassenger::getDestination()
{
    return m_DestinationFloor;
}

float ElevatorPassenger::getWeight()
{
    return m_Weight;
}

void ElevatorPassenger::setWeight(float weight)
{
	m_Weight = weight;
}

void ElevatorPassenger::deserialize(char *stream)
{
	char * p = stream;

	memcpy((void*)&m_DestinationFloor,(void*)p,sizeof(m_DestinationFloor));

	p += sizeof(m_DestinationFloor);

	memcpy((void*)&m_Weight,(void*)p,sizeof(m_Weight));
}



void ElevatorPassenger::serialize(char *stream)
{
	char * p = stream;

	memcpy((void*)p,(void*)&m_DestinationFloor,sizeof(m_DestinationFloor));

	p += sizeof(m_DestinationFloor);

	memcpy((void*)p,(void*)&m_Weight,sizeof(m_Weight));
}



int ElevatorPassenger::byteSize()
{
	return sizeof(m_DestinationFloor)+sizeof(m_Weight);
}

void ElevatorPassenger::setDestination(FloorIdentifier destination)
{
	m_DestinationFloor = destination;
}

std::string ElevatorPassenger::toPrettyString()
{
	stringstream ss;

	ss << "Destination:"<<m_DestinationFloor;

	return ss.str();
}


